#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    vector<string> findWords(vector<string>& words) {
        string s1 = "qwertyuiopQWERTYUIOP";
        string s2 = "asdfghjklASDFGHJKL";
        string s3 = "zxcvbnmZXCVBNM";
        map<char, int> m;
        for (auto e : s1) m[e] = 1;
        for (auto e : s2) m[e] = 2;
        for (auto e : s3) m[e] = 3;

        vector<string> ret;
        for (int i = 0; i < words.size(); i++)
        {
            if (words[i].size() == 1)
            {
                ret.push_back(words[i]);
                continue;
            }
            int j = 1;
            for (; j < words[i].size(); j++)
            {
                if (m[words[i][j]] != m[words[i][j - 1]])
                {
                    break;
                }
            }
            if (j == words[i].size())
            {
                ret.push_back(words[i]);
            }
        }
        return ret;

    }
};